package com.ming.study.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Component
@Data

@PropertySource("classpath:/jwSystem.properties")
@ConfigurationProperties(prefix = "jwsystem.kd")
public class JwPropertiesUtil implements InitializingBean {
    private int cookieTime;
    private int networkTime;

    private String baseUrl;
    private String loginUrl;
    private String encodedUrl;
    private String indexUrl;
    private String weekUrl;
    private String courseScheduleUrl;
    private String searchCourseUrl;
    private String logOnUrl;
    private String userInfoUrl;
    private String courseScoreUrl;
    private String certificateScoreUrl;
    private String examScheduleUrl;
    private String defaultTermUrl;

    public static int COOKIE_TIME;      // cookie过期时间7200s
    public static int NETWORK_TIME;     // 网络请求时长
    public static String BASE_URL;      // 基础地址
    public static String LOGIN_URL;     // 登录
    public static String ENCODED_URL;   // 验证码
    public static String INDEX_URL;     // 首页
    public static String WEEK_URL;      // 周次
    public static String COURSE_SCHEDULE_URL;    // 课程
    public static String SEARCH_COURSE_URL; // 通过日期，课程搜索
    public static String USER_INFO_URL; // 用户信息
    public static String COURSE_SCORE_URL;  // 课程成绩
    public static String CERTIFICATE_SCORE_URL; // 证书成绩
    public static String EXAM_SCHEDULE_URL; // 考试安排
    public static String DEFAULT_TERM_URL;  // 默认学期日期


    @Override
    public void afterPropertiesSet() throws Exception {
        COOKIE_TIME = cookieTime;
        NETWORK_TIME = networkTime;

        BASE_URL = baseUrl;

        LOGIN_URL = BASE_URL + loginUrl;
        ENCODED_URL = BASE_URL + encodedUrl;
        INDEX_URL = BASE_URL + indexUrl;
        WEEK_URL = BASE_URL + weekUrl;
        COURSE_SCHEDULE_URL = BASE_URL + courseScheduleUrl;
        SEARCH_COURSE_URL = BASE_URL + searchCourseUrl;
        USER_INFO_URL = BASE_URL + userInfoUrl;
        COURSE_SCORE_URL = BASE_URL + courseScoreUrl;
        CERTIFICATE_SCORE_URL = BASE_URL + certificateScoreUrl;
        EXAM_SCHEDULE_URL = BASE_URL + examScheduleUrl;
        DEFAULT_TERM_URL = BASE_URL + defaultTermUrl;

    }
}
